package com.winshare.saleAssistant.domain.dto.req;

import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModelProperty;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;

public class StatisticReq5DTO {

    @NotBlank(message = "开始时间不能为空")
    @ApiModelProperty(value = "开始时间,格式为：yyyy-dd-mm")
    @Pattern(regexp = "(\\d{4}|\\d{2})-((1[0-2])|(0?[1-9]))-(([12][0-9])|(3[01])|(0?[1-9]))",message = "格式为：yyyy-dd-mm")
    private String startDate;

    @NotBlank(message = "结束时间不能为空")
    @ApiModelProperty(value = "结束时间,格式为：yyyy-dd-mm")
    @Pattern(regexp = "(\\d{4}|\\d{2})-((1[0-2])|(0?[1-9]))-(([12][0-9])|(3[01])|(0?[1-9]))",message = "格式为：yyyy-dd-mm")
    private String endDate;

    @NotNull(message = "排序类型不能为空")
    @Range(min = 1,max = 2,message = "排序类型：1.升序，2.降序")
    @ApiModelProperty(notes = "排序类型：1.升序，2.降序")
    private Integer orderType;

    @NotNull(message = "每页数量不能为空")
    @Range(min = 1, message = "每页数量必须大于或等于1")
    @ApiModelProperty(value = "每页数量，建议10-20")
    private Integer pageSize;

    @NotNull(message = "第几页 字段为能为空")
    @Range(min = 1, message = "页号至少从第1页开始")
    @ApiModelProperty(value = "第几页，从1开始")
    private Integer pageIndex;

    @JsonIgnore
    @ApiModelProperty(hidden = true)
    public Integer getOffsetIndex() {
        return pageSize * (pageIndex < 1 ? 0 : pageIndex-1);
    }

    public StatisticReq5DTO() {
    }

    public String getStartDate() {
        return startDate;
    }

    public void setStartDate(String startDate) {
        this.startDate = startDate;
    }

    public String getEndDate() {
        return endDate;
    }

    public void setEndDate(String endDate) {
        this.endDate = endDate;
    }

    public Integer getOrderType() {
        return orderType;
    }

    public void setOrderType(Integer orderType) {
        this.orderType = orderType;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public Integer getPageIndex() {
        return pageIndex;
    }

    public void setPageIndex(Integer pageIndex) {
        this.pageIndex = pageIndex;
    }
}
